<div class="pull-left span9">
	<table class="table">
		<thead>
			<tr>
				<th></th>
				<th>id</th>
				<th>วันที่</th>
				<th>กำหนดชำระ</th>
				<th style="text-align: center; width: 100px;">ยอดเงิน</th>
				<th style="text-align: center;">สถานะ</th>
				<th></th>
			</tr>
		</thead>
		<tbody>
			<?php
			foreach ($params['invoices'] as $key => $invoice){
			switch ($invoice['status']) {
				case Invoice::STATUS_PAY: $status = 'ชำระแล้ว'; $classStatus="success"; break;
				case Invoice::STATUS_CHECK: $status = 'รอตรวจสอบ'; $classStatus="warning"; break;
				default: $status = 'ยังไม่ได้ชำระ'; $classStatus="error"; break;
			}
			?>
			<tr class="<?php echo $classStatus;?>">
				<td><?php if($invoice['status']==0){?><input type="checkbox" class="payCheckbox" value="<?php echo $invoice['id'];?>" /><?php }?></td>
				<td><?php echo $invoice['id'];?></td>
				<td><?php $dateTime = new DateTime($invoice['dateCreate']); echo $dateTime->format('j/m/Y');?></td>
				<td><?php $dateTime = new DateTime($invoice['dateDue']);  echo $dateTime->format('j/m/Y');?></td>
				<td style="text-align: right;"><?php echo Helper::formatMoney($invoice['price'], true);?> บาท</td>
				<td style="text-align: center;"><?php echo $status;?></td>
				<td><a target="_blank" href="index.php?page=invoice&id=<?php echo $invoice['id'];?>">detail</a></td>
			</tr>
			<?php }?>
		</tbody>
	</table>
	<div>
		<button type="button" class="btn payButton">แจ้งชำระเงิน</button>
	</div>
</div>
<div class="clear"></div>
<script type="text/javascript">
$(function(event){
	$('.payButton').click(function(event){
		event.preventDefault();
		var ivids = [];
		$('.payCheckbox:checked').each(function(index, el){
			ivids.push($(el).val());
		});
		if(ivids.length == 0){
			$('.payMessage').text('คุณยังไม่ได้เลือกใบแจ้งชำระเงิน').show().addClass('in');
			return;
		}
		var inv = ivids.join(',');
		location.href = 'index.php?page=payment&invoiceId='+inv;
	});
});
</script>